<?php

namespace Api\Event;


/** 
 * 图标包接口
 * @author Legend. <xcx_legender@qq.com>
 * @param 
 * @return 
 */

class IconPacksEvent extends BaseEvent 
{


	/** 
	 * 获取pack包下所有的icons
	 * @author Legend. <xcx_legender@qq.com>
	 * @param 
	 * @return 
	 */
	
	public function getIcons($pack_id)
	{
		$model = D('Common/Icon', 'Service');
		$map['pack_id'] = intval($pack_id);
		$map['status'] = array('egt',0);
		return $model->where($map)->select();
	}


	/** 
	 * 根据id获取相应的icon数据 
	 * @author Legend. <xcx_legender@qq.com>
	 * @param  
	 * @return 
	 */
	
	public function getIconsByIds($id = 0)
	{
		if (!is_array($id))
		{
			$id = array( $id );
		}
		$map['id'] = array('in', array_map('intval', $id));
		$map['status'] = array('egt',0);
		$model = D('Common/Icon', 'Service');
		$res = $model->where($map)->select();
		return $res;
	}


	public function getIconById($id = 0)
	{
		$icon = array_values($this->getIconsByIds($id))[0];
		uri_format($icon['pic']);
		return $icon;
	}


	/** 
	 * 获取某分类下的pack包信息   PS: 7.1版本只给出默认的包  暂时不使用
	 * @author Legend. <xcx_legender@qq.com>
	 * @param 
	 * @return 
	 */
	
	public function getPacks($type)
	{
		$model = D('Common/IconPacks', 'Service');
		$map['type'] = $type;
		$list = $model->where($map)->select();
		return $list;
	}

}